﻿using System.Web.Mvc;

namespace MvcForum.Net.Bussiness
{
    public class ValidateIpAddressAttribute : ActionFilterAttribute
    {


        public string ReturnUrl { get; set; }

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            var _context = filterContext.HttpContext;

            if (_context != null)
            {

                if (ForumContext.IpAddressIsBanned())
                {
                    if (!string.IsNullOrWhiteSpace(ReturnUrl))
                    {
                        _context.Response.Redirect(ReturnUrl, true);
                    }
                    else
                    {
                        _context.Response.End();
                    }
                }

            }

            //base.OnActionExecuting(filterContext);

        }
    }
}
